﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaxAlarm.Common;
using MaxAlarm.Common.Alarms;
using MaxAlarm.Common.Data;

namespace MaxAlarm.AlarmActions
{
    public static class ActionManager
    {
        private static readonly Dictionary<AlarmAction, Func<AlarmItem, AlarmActionBase>> _actionMap = new Dictionary
            <AlarmAction, Func<AlarmItem, AlarmActionBase>>
                                                                                 {
                                                                                     {AlarmAction.CheckAfter, (AlarmItem item)=>
                                                                                                                  {
                                                                                                                      return new CheckAfterAlarmAction(item);
                                                                                                                  }},

                                                                                    {AlarmAction.Ignore, (AlarmItem item)=>
                                                                                                                    {
                                                                                                                        return new IgnoreAlarmAction(item);
                                                                                                                    }},

                                                                                     {AlarmAction.Immediately, (AlarmItem item)=>
                                                                                                                    {
                                                                                                                        return new ImmediatelyAlarmAction(item);
                                                                                                                    }},


                                                                                 };

        public static Func<AlarmItem, AlarmActionBase> CreateAction(AlarmAction action, AlarmItem item)
        {
            return _actionMap[action];
        }
    }
}
